import { getProcessListReq } from "../../../Api/processingplant/process_factory"
// import { getProcessListByBaseId, getStaffListByBaseId } from "../../../Api/processingplant/index"
// import { processingplantInfo } from "./processingplantInfo"
const process = {
    namespaced: true,

    state: {
        processList: [], // 加工厂信息
        staffList: [], // 管理员信息列表
        materialList: [], // 加工厂原料信息列表
        productList: [],  // 加工产品信息列表
        columns: [ // 表头数据
            { name: "创建时间", show: false, prop: 'gmt_create' },
            { name: "修改时间", show: false, prop: 'gmt_modified' },
            { name: "名称", show: true, prop: 'name' },
            { name: "ID", show: true, prop: 'id' },
            { name: "所属企业id", show: true, prop: 'enterprise_id' },
            { name: "地址", show: true, prop: 'address' },
            { name: "面积", show: false, prop: 'area' },
        ],
        layout: 'search, refresh, column', // 表头右侧显示功能
    },

    mutations: {
        setProcessList(state, payload) {
            state.processList = payload;
        },
        setStaffList(state, payload) {
            state.staffList = payload;
        }
    },

    actions: {
        async getProcessList({ commit }, baseId) {
            const { data: res } = await getProcessListReq();
            console.log('加工厂列表');
            console.log(res);
            if (res.statusCode !== 20000) {
                console.log(res.message);
                return
            }
            console.log(res.data);
            commit("setProcessList", res.data);
        },
        async getStaffList({ commit }, baseId) {
            const { data: res } = await getStaffListByBaseId(baseId);
            console.log('res: ', res);
            if (res.statusCode !== 20000) {
                console.log(res.message);
                return
            }
            commit("staffList", res.data);
        },
        async getMaterialList({ commit }, processId) {
            const { data: res } = await getMaterialListByProcessId(processId);
            console.log('res: ', res);
            if (res.statusCode !== 20000) {
                console.log(res.message);
                return
            }
            commit("materialList", res.data);
        },
        async getProductList({ commit }, processId) {
            const { data: res } = await getProductListByProcessId(processId);
            console.log('res: ', res);
            if (res.statusCode !== 20000) {
                console.log(res.message);
                return
            }
            commit("productList", res.data);
        }
    }
    ,
    // modules:{
    //     processingplantInfo
    // }
}

export default process